feat(sdk-coin-sui): update balance querying to handle fundsInAddressBalance field#8332
feat(sdk-coin-sui): update balance querying to handle fundsInAddressBalance field#8332abhishekagrawal080 merged 1 commit intomasterfrom
Conversation
84b8b55 to
85e268b
Compare
85e268b to
c32b2a2
Compare
d4060cc to
cadeda0
Compare
cadeda0 to
9f29947
Compare
9f29947 to
5e9a6d0
Compare
|
@claude Please do a thorough review of this PR. Focus especially on:
Please call out concrete issues clearly and separate them by severity if possible. |
PR Review: #8332 — feat(sdk-coin-sui): update balance querying to handle fundsInAddressBalance fieldAuthor: @abhishekagrawal080 | URL: #8332 1. SummaryThis PR extends the Sui SDK to support the new Changes at a Glance
Dataflow DiagramsequenceDiagram
participant Caller
participant Sui as sui.ts recover()
participant Utils as utils.getBalance()
participant RPC as suix_getBalance (Sui RPC)
participant Builder as TransferBuilder / TokenTransferBuilder
participant TB as TransactionBlock
Caller->>Sui: recover(params)
Sui->>Utils: getBalance(senderAddress)
Utils->>RPC: suix_getBalance([owner, coinType])
RPC-->>Utils: { totalBalance, fundsInAddressBalance }
Utils-->>Sui: SuiBalanceInfo { totalBalance, coinObjectBalance, fundsInAddressBalance }
alt Case 2: all funds in address balance (no coin objects)
Sui->>Utils: getChainContext(url)
Utils->>RPC: suix_getLatestSuiSystemState + sui_getChainIdentifier
RPC-->>Utils: { epoch, chainId }
Sui->>Builder: expiration({ ValidDuring: { minEpoch, maxEpoch, chain, nonce } })
end
Sui->>Builder: fundsInAddressBalance(amount)
Builder->>TB: withdrawal({ amount, type })
TB-->>Builder: BalanceWithdrawalCallArg
Builder->>TB: moveCall("0x2::coin::redeem_funds", [withdrawal])
TB-->>Builder: Coin<T>
Builder->>TB: mergeCoins / splitCoins / transferObjects
Notable Changes
2. Ticket AlignmentTicket: CSHLD-407 — SUI: Update balance querying to handle fundsInAddressBalance field Intent Match:
|
| Severity | Finding | Location |
|---|---|---|
any() in BalanceWithdrawalCallArg superstruct — loses validation for amount and type_ |
Inputs.ts:67-69 |
|
as any[] / input: any when scanning for BalanceWithdrawal inputs |
tokenTransferBuilder.ts:317, transferBuilder.ts:698 |
|
as SuiCoin cast without guard — invalid coinType silently if not SuiCoin |
tokenTransferBuilder.ts:292 |
|
fundsInAddressBalance: optional(number()) should be optional(string()) — u64 overflow risk |
coin.ts:177 |
|
Negative coinObjectBalance possible if RPC returns fundsInAddressBalance > totalBalance |
utils.ts:954 |
|
| ℹ️ | tx as any in MoveCall type detection — narrower cast available |
transaction.ts:566 |
| ℹ️ | getIdFromCallArg returns '' for BalanceWithdrawal — dedup risk if multiple withdrawals |
Inputs.ts:103 |
| ℹ️ | PR scope significantly exceeds CSHLD-407 — builder/BCS/expiration work likely belongs to CSHLD-409 | multiple files |
Generated by [wallet-platform:review-pr] via Claude Code
3f32c23 to
4aa1ac8
Compare
|
@abhishekagrawal080 Is there any staking related changes that's required? |
lokesh-bitgo
left a comment
There was a problem hiding this comment.
WP Changes looks good
…alance field TICKET: CSHLD-407
4aa1ac8 to
6ea2bc8
Compare
TICKET: CSHLD-407